home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / tools / mg / rexx / compile.mg < prev    next >
Text File  |  1995-03-09  |  2KB  |  67 lines

  1. /*
  2.  * Run a compile, and put the output back into the buffer "*compilation*"
  3.  * in the mg we started from.
  4.  */
  5.  
  6. options results
  7. options failat 2
  8. signal on failure
  9.  
  10. /* Constant strings */
  11. clipname = "mg.compile-command"
  12. bufname = "*compilation*"
  13. tmpfile = 'ram:'address()
  14.  
  15. /* I need the suppor library (later) */
  16. if ~show('Libraries', 'rexxsupport.library') then
  17.     if ~addlib('rexxsupport.library', 0, -30, 0) then do
  18.         'rexx-display "Can''t open rexx support library!"'
  19.         exit 2
  20.         end
  21.  
  22. /* Get the command to run, defaulting to any previous value */
  23. command = getclip(clipname)
  24. if command = "" then do
  25.     call mgclip clipname
  26.     command = "make -k"
  27.     end
  28. 'rexx-request "Compile command ('command'): "'
  29. if rc = 0 then command = result
  30. call setclip clipname, command
  31. call mgclip clipname
  32.  
  33. /* release the editor, and run the compile */
  34. if savesomebuffers() ~= 0 then signal failure
  35. 'rexx-display Compiling...'
  36. 'rexx-unlock'
  37. address value result
  38. options failat 20
  39. address command command '>'tmpfile
  40.  
  41. /* Get my editor back, and load the buffer with the results */
  42. options failat 4        /* 4 -> no rexx left; anything less we ignore */
  43. 'rexx-lock'
  44. do while rc ~= 0
  45.     call delay 50
  46.     'rexx-lock'
  47.     end
  48. address value result
  49. lockadd = result
  50. options failat 2
  51. 'rexx-display "Compilation complete"'
  52. 'switch-to-buffer-other-window' bufname
  53. 'not-modified'
  54. 'kill-buffer' bufname
  55. 'switch-to-buffer' bufname
  56. 'insert-file' tmpfile
  57. 'other-window'
  58. 'rexx-unlock'
  59. address command 'delete' tmpfile
  60. exit 0
  61.  
  62. failure:
  63.     'rexx-display "Compilation failed"'
  64.     if exists(tmpfile) then address command 'delete' tmpfile
  65.     if lockadd = address() then 'rexx-unlock'
  66.     exit 2
  67.